import React, { Component } from 'react'

import { apilink } from '../../api/apilink';
import Oneorder from "../../components/order/oneorder"
import {SOrder} from "../../styled/order"

export default class Noshouhuo extends Component {
    constructor(props){
        super(props)
        this.state={
            order_goods:"",
            order_pay:""
        }
    }
    componentDidMount(){
        let usp = new URLSearchParams();
            usp.append("userId",sessionStorage.getItem("userId"));
        apilink("/api/get_order_for_goods","post",usp).then((ok)=>{
            console.log(ok.data)
            this.setState({
                order_goods:ok.data,
                
            })
        })
    }
    //待收货
    one_dingdan=()=>{
        let newarr = []
        this.state.order_goods.forEach((item,index)=>{
            if(item.wuliu){
                newarr.push(item);
            }
        });
        if(newarr.length === 0){
            return
        }
        console.log(newarr)
        return newarr.map((item,index)=>{
            return (<Oneorder orderInfo={item} key={index}></Oneorder>)
        })
    }
    render() {
        return (
            <div>
                {/* <Header></Header> */}
                <div>
                    <SOrder>
                    <h1>我的订单--待收货</h1>
                    <div className="onegoods">
                        <div className="order">

                        {this.state.order_goods?this.one_dingdan():""}
                        </div>
                        
                    </div>
                    </SOrder>
                </div>
                {/* <Footer></Footer> */}
            </div>
        )
    }
}
